package com.lucian.ge.service.stockinfo.controller;

import com.lucian.ge.comman.model.ResultMap;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;


import java.util.*;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
 * Created by Lucicol on 2019/5/8.
 */
@Api(value = "IndexController", description = "新闻")
@RestController
@RequestMapping("/news")
public class NewsController {
    @Value("${com.stockURL}")
    private String stockURL;
    private final ResultMap resultMap;

    @Autowired
    public NewsController( ResultMap resultMap) {
        this.resultMap = resultMap;
    }

    @ApiOperation(value="股市新闻", notes="")
    @GetMapping("/top_news")
    public ResultMap getMoreIndex() {
        RestTemplate restTemplate = new RestTemplate();
        String result = restTemplate.getForObject(stockURL + "/news", String.class);
        return resultMap.success().code(200).message("更多指数").data(JSON.parseArray(result));
    }
}

